﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../include/header.jsp" %>
<div id="main">
    <form action="" method="">
        <!--查询-->
        <div class="search_add">
            <input type="button" value="增加" class="btn_add" onclick="location.href='${pageContext.request.contextPath}/RolePrivsAction.do'" />
        </div>
        <!--删除的操作提示-->
        <div id="operate_result_info" class="operate_success">
            <img src="../images/close.png" onclick="this.parentNode.style.display='none';" />
            删除成功！
        </div> <!--删除错误！该角色被使用，不能删除。-->
        <!--数据区域：用表格展示数据-->
        <div id="data">
            <table id="datalist">
                <tr>
                    <th>角色 ID</th>
                    <th>角色图片</th>
                    <th>角色名称</th>
                    <th class="width600">拥有的权限</th>
                    <th class="td_modi"></th>
                </tr>
                <c:forEach items="${lr }" var="role">
                    <tr>
                        <td>${role.id }</td>
                        <td><img src="${pageContext.request.contextPath}${role.by001}" height="40" width="40"/></td>
                        <td>${role.rname }</td>
                        <td>${role.privs }</td>
                        <td>
                            <input type="button" value="修改" class="btn_modify" onclick="location.href='${pageContext.request.contextPath}/ShowUpdateRole.do?rid='+${role.id};"/>
                            <input type="button" value="删除" class="btn_delete" onclick="deleteRole('${role.id}');" />
                        </td>
                    </tr>
                </c:forEach>
            </table>
        </div>
        <!--分页-->
        <div id="pages">
            <a href="#">上一页</a>
            <a href="#" class="current_page">1</a>
            <a href="#">2</a>
            <a href="#">3</a>
            <a href="#">4</a>
            <a href="#">5</a>
            <a href="#">下一页</a>
        </div>
    </form>
</div>
<script language="javascript" type="text/javascript">
    function deleteRole(rid) {
        var r = window.confirm("确定要删除此角色吗？");
        if(r){
            location.href="${pageContext.request.contextPath}/RoleDelAction.do?rid="+rid;
        }
    }
    $(function(){
        $(".role_off").attr("class","role_on");

        var msg = '${state}';
        if(msg === '1'){
            $("#operate_result_info").text("删除成功");
            $("#operate_result_info").attr("class","operate_success");
            $("#operate_result_info").css("display","block");
        }else if(msg === '0'){
            $("#operate_result_info").text("删除失败");
            $("#operate_result_info").attr("class","operate_fail");
            $("#operate_result_info").css("display","block");
        }
        setTimeout('$("#operate_result_info").css("display","none");' ,2000);
    })
</script>
<!--主要区域结束-->
<div id="footer">

</div>
</body>
</html>
